local name, DB = ...

local recorder = CreateFrame"Frame"

recorder:SetScript("OnEvent", function (self, _, ts, event, ...)
	local handlers = self[event]
	if handlers then
		for _, handler in next, handlers do
			handler(ts, event, ...)
		end
	end
end)
recorder:RegisterEvent"COMBAT_LOG_EVENT_UNFILTERED"

function recorder:AddHandler(events, handler)
	if type(events) == "table" then
		for _, event in next, events do
			self:AddHandler(event, handler)
		end
	else
		local handlers = self[events]
		if not handlers then
			handlers = {}
			self[events] = handlers
		end
		handlers[#handlers + 1] = handler
	end
end

DB.recorder = recorder
